import {
  getCustomerList as getSelectCustomerList,
  getDeliveryMethodList as getMesSalesOrderDeliveryMethodList,
  getFactoryCodeList as getMesSalesOrderFactoryCodeList,
  getCustomerTypeNameList,
  getCustomerTypeValueList
} from '@/api/order/mesSalesOrder'

export const mesCustomerDialog = {
  data() {
    return {
      mesCustomerDialogVisible: false, //表格弹框隐藏显示
      getSelectCustomerList, // 获取弹框数据接口
      hasMesSalesOrderFooter: true, // 是否需要底部按钮默认true
      mesCustomerSearchDialog: {
        inline: true,
        formDesc: {
          customerCode: {
            type: 'input',
            layout: 8,
            label: $i18n.t('mesSalesOrder.customerCode')
          },
          customerName: {
            type: 'input',
            layout: 8,
            label: $i18n.t('mesSalesOrder.customerName')
          },
          customerTypeValue: {
            type: 'select',
            label: $i18n.t('mesSalesOrder.customerType'),
            layout: 8,
            prop: {
              value: 'value',
              text: 'description'
            },
            options: async (data) => {
              const list = await getCustomerTypeValueList()
              return list.data.result
            }
          }
        }
      },
      mesCustomerDialogColumn: [
        {
          type: 'selection',
          fixed: 'left'
        },
        {
          type: 'index',
          label: $i18n.t('common.order'),
          fixed: 'left',
          width: 60
        },
        {
          prop: 'customerCode',
          label: $i18n.t('mesSalesOrder.customerCode'),
          width: 120,
          fixed: 'left'
        },
        {
          prop: 'customerName',
          label: $i18n.t('mesSalesOrder.customerName'),
          width: 270
        },
        {
          prop: 'address',
          label: $i18n.t('mesSalesOrder.address'),
          width: 270
        },
        {
          prop: 'contacts',
          label: $i18n.t('mesSalesOrder.contacts'),
          width: 100
        },
        {
          prop: 'mobilePhone',
          label: $i18n.t('mesSalesOrder.mobilePhone'),
          width: 140
        },
        {
          prop: 'telephone',
          label: $i18n.t('mesSalesOrder.telephoneFixed'),
          width: 120
        },
        {
          prop: 'customerTypeValue',
          label: $i18n.t('mesSalesOrder.customerType'),
          width: 120,
          optionProp: {
            value: 'value',
            label: 'description'
          },
          option: async (data) => {
            const list = await getCustomerTypeValueList()
            return list.data.result
          }
        },
        // {
        //   prop: "customerTypeName",
        //   label: "客商类别",
        //   width: 120,
        //   optionProp: {
        //     value: "value",
        //     label: "description",
        //   },
        //   option: async (data) => {
        //     const list = await getCustomerTypeNameList()
        //     self.skillCodeList = list.data.result;
        //     return list.data.result;
        //   },
        // },
        // {
        //   prop: "qualityType",
        //   label: "质检状态",
        //   width: 120,
        //   optionProp: {
        //     value: "value",
        //     label: "description",
        //   },
        //   option: async (data) => {
        //     const list = await getQualityTypeList()
        //     return list.data.result
        //   },
        // },
        {
          prop: 'factoryCode',
          label: $i18n.t('mesSalesOrder.factoryCode'),
          width: 120
        },
        // {
        //   prop: "remark",
        //   label: "备注",
        // },
        {
          prop: 'createByName',
          label: $i18n.t('common.createByName'),
          width: 120
        },
        {
          prop: 'createTime',
          label: $i18n.t('common.createTime'),
          width: 200
        },
        {
          prop: 'updateByName',
          label: $i18n.t('common.updateByName'),
          width: 130
        },
        {
          prop: 'updateTime',
          label: $i18n.t('common.updateTime'),
          width: 200
        }
      ]
    }
  },
  methods: {
    // 弹框表格，双击表格，或者点击确定 返回选中数据
    getSelectCustomer(data) {
      // 调试完成记得删除控制台打印
      console.log('选中数据', data)
      // 这里可以自定义返回字段信息
      // 第一个入参为当前表单绑定的对象，第二个入参为要修改的字段名，第三个入参为选中数据中相应信息
      this.$set(this.formDataDialog, 'customerCode', data[0].customerCode)
      this.$set(this.formDataDialog, 'customerName', data[0].customerName)
      this.$set(this.formDataDialog, 'deliveryAddress', data[0].address)
    }
  }
}
